<extend name="Base:base" />
<block name="head">
    <import type="css" file="css/page/node" />
    <script type="text/javascript">
        $(function(){
            $('input[level=1]').click(function(){
                var inputs = $(this).parents('.app').find('input');
                $(this).prop('checked') ? inputs.prop('checked','checked') : inputs.removeProp('checked');
            });
            $('input[level=2]').click(function(){
                var inputs = $(this).parents('dl').find('input');
                $(this).prop('checked') ? inputs.prop('checked','checked') : inputs.removeProp('checked');
            });
            
        });
    </script>
</block>
<block name="title">{$title}</block>
<block name="content">
    <form action="{:U('Admin/Rbac/setAccess')}" method="post">
        <div id="wrap">
            <a href="{:U('Admin/Rbac/role')}" class="add-app">返回</a>        
            <foreach name="nodes" item="app">
                <div class="app">
                    <p>
                        <strong>{$app.title}</strong>
                    <input type="checkbox" name="access[]" value="{$app.id}_1" level="1" <if condition='$app[access]'>checked='checked'</if> />
                    </p>
                    <foreach name="app.child" item="action">
                        <dl>
                            <dt>
                            <strong>{$action.title}</strong>
                            <input type="checkbox" name="access[]" value="{$action.id}_2" level="2" <if condition='$action[access]'>checked='checked'</if>/>
                            </dt>
                            <foreach name="action.child" item="method">
                                <dd>
                                    <span>{$method.title}</span>
                                    <input type="checkbox" name="access[]" value="{$method.id}_3" level="3" <if condition='$method[access]'>checked='checked'</if>/>
                                </dd>
                            </foreach>
                        </dl>
                    </foreach>
                </div>
            </foreach>        
        </div>
        <input type="hidden" value="{$rid}" name="rid" />
        <input type="submit" value="保存修改" style="display:block;margin: 20px auto;cursor: pointer;"/>
    </form>
</block>
